package com.bitoon.basketdudes.jpa;

import com.bitoon.basketdudes.jpa.*;
import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * @author PacoFELC 2012
 */
@Entity
@Table(name = "amigo", schema = "central")
@NamedQueries({
    @NamedQuery(name = "Amigo.findAll"          , query = "SELECT v FROM Amigo v"),
    @NamedQuery(name = "Amigo.countAll"          , query = "SELECT count(v) FROM Amigo v WHERE v.amigoPK.propietario = :propietario"),
    @NamedQuery(name = "Amigo.findByPropietario", query = "SELECT v FROM Amigo v WHERE v.amigoPK.propietario = :propietario"),
    @NamedQuery(name = "Amigo.findElemento"     , query = "SELECT v FROM Amigo v WHERE v.amigoPK.propietario = :propietario and v.amigoPK.usuarioId = :usuario_id")
})
public class Amigo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AmigoPK amigoPK;

    public Amigo()  {
    }

    public Amigo(AmigoPK amigoPK) {
        this.amigoPK = amigoPK;
    }

    public Amigo(int usuarioId, short servicioId) {
        this.amigoPK = new AmigoPK(usuarioId, servicioId);
    }

    public AmigoPK getAmigoPK() {
        return amigoPK;
    }

    public void setAmigoPK(AmigoPK amigoPK) {
        this.amigoPK = amigoPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (amigoPK != null ? amigoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Amigo)) {
            return false;
        }
        Amigo other = (Amigo) object;
        if ((this.amigoPK == null && other.amigoPK != null) || (this.amigoPK != null && !this.amigoPK.equals(other.amigoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.basketdudes.jpa.Amigo[amigoPK=" + amigoPK + "]";
    }

}
